import {
  Entity,
  Column,
  PrimaryGeneratedColumn,
  CreateDateColumn,
} from 'typeorm';
import { ApiProperty } from '@nestjs/swagger';

@Entity()
export class Topic {
  @ApiProperty({ description: '话题 ID', example: 1 })
  @PrimaryGeneratedColumn()
  id: number;

  @ApiProperty({ description: '话题标题', example: '新话题标题' })
  @Column()
  title: string;

  @ApiProperty({ description: '话题内容', example: '这是话题的具体内容' })
  @Column({ type: 'text' })
  content: string;

  @ApiProperty({ description: '用户 ID', example: 1 })
  @Column()
  userId: number;

  @ApiProperty({
    description: '话题媒体文件地址（视频或图片）',
    example: 'https://example.com/image.jpg',
  })
  @Column({ nullable: true }) // 允许该字段为空
  mediaUrl: string;

  @ApiProperty({
    description: '话题创建时间',
    example: '2025-05-05T13:39:39.000Z',
  })
  @CreateDateColumn()
  createdAt: Date;
}
